import 'package:shared_preferences/shared_preferences.dart';

class ConfigUtil {
  static const ARTICLE_SOURCE = "ARTICLE_SOURCE";
  static const INTERFACE_ADDRESS = "InterfaceAddress";
  static const XML_ADDRESS = "XML_ADDRESS";

  static Future<bool> setArticleSource(String value) async{
    var sp = await SharedPreferences.getInstance();
    return sp.setString(ARTICLE_SOURCE,value ?? "");
  }

  static Future<String> getArticleSource() async{
    var sp = await SharedPreferences.getInstance();
    return sp.getString(ARTICLE_SOURCE) ?? "VanBlog";
  }

  static Future<bool> setInterfaceAddress(String value) async{
    var sp = await SharedPreferences.getInstance();
    return sp.setString(INTERFACE_ADDRESS,value ?? "");
  }

  static Future<String> getInterfaceAddress() async{
    var sp = await SharedPreferences.getInstance();
    return sp.getString(INTERFACE_ADDRESS) ?? "43.139.85.46";
  }

  static Future<bool> setXmlAddress(String value) async{
    var sp = await SharedPreferences.getInstance();
    return sp.setString(XML_ADDRESS,value ?? "");
  }

  static Future<String> getXmlAddress() async{
    var sp = await SharedPreferences.getInstance();
    return sp.getString(XML_ADDRESS) ?? "http://43.139.85.46/feed.xml";
  }
}